import request from '@/utils/request'

// 获取模板列表
export function getModel() {
  return request({
    url: '/admin/model',
    method: 'get'
  })
}

// 创建模板
export function createModel(data) {
  return request({
    url: '/admin/model',
    method: 'post',
    data: data
  })
}

// 更新模板信息
export function updateModel(data) {
  return request({
    url: '/admin/model',
    method: 'put',
    data: data
  })
}

// 获取当前模板
export function getModelInfo(modelId) {
  return request({
    url: `/admin/model/${modelId}`,
    method: 'get'
  })
}

// 保存模板流程
export function saveModel(data) {
  return request({
    url: `/admin/model/json/${data.id}`,
    method: 'post',
    data: data
  })
}

// 创建实例
export function deployModel(data) {
  return request({
    url: `/admin/instance`,
    method: 'post',
    data: data
  })
}

// 删除模板
export function deleteModel(modelId) {
  return request({
    url: `/admin/model/${modelId}`,
    method: 'delete'
  })
}

// 获取流程实例列表
export function getProcList(modelKey) {
  return request({
    url: `/admin/instance/${modelKey}`,
    method: 'get'
  })
}

// 获取流程json
export function getCurFlowchartJson(procInstId) {
  return request({
    url: `/admin/instance/json/${procInstId}`,
    method: 'get'
  })
}

// 保存实例json
export function saveDeploy(data) {
  return request({
    url: `/admin/instance`,
    method: 'put',
    data: data
  })
}

// 获取正在进行的节点ID
export function getCurProcInstId(procInstId) {
  return request({
    url: `/admin/instance/act/${procInstId}`,
    method: 'get'
  })
}

// 批转
export function nextApi(data) {
  return request({
    url: `/admin/instance/${data.procInstId}/${data.actId}`,
    method: 'post'
  })
}

// 可以回退列表
export function backCurProcInstIdList(data) {
  return request({
    url: `/flow/back/list/${data.modelId}/${data.procInstId}/${data.currentTaskDefKey}`,
    method: 'get'
  })
}

// 回退
export function backCurProcInstId(data) {
  return request({
    url: `/flow/back/${data.modelId}/${data.procInstId}/${data.currentTaskDefKey}/${data.targetTaskDefKey}`,
    method: 'get'
  })
}

// 获取可以减签id
export function deleteNodeIdList(data) {
  return request({
    url: `/flow/sign/list/${data.modelId}/${data.procInstId}`,
    method: 'get'
  })
}
